<div class="boxed clearfix">
<script type="text/javascript" language="javascript" charset="utf-8">
$(".header-con li a").removeClass("open-menu");
$(".header-con li #home").addClass("open-menu");
</script>

  <!-- <%= debug @studioDataArray %> -->

  <% @studioDataArray.each do |studio| %>
    <div class="atelier">
      <div class="ate-tip-name" data_id="<%= studio["id"] %>">
        <h2><%= studio["name"] %></h2>
        <div class="clearfix">
          <span></span>
          <em>到期时间：<%= studio["invalidate_at"].strftime("%Y-%m-%d") %></em>
        </div>
      </div>
      <div class="ate-tip-input" data_id="<%= studio["id"] %>">
        <input class="ate-changing" type="text" maxlength="15"  placeholder="店铺名" value="<%= studio["name"] %>">  <a class="ate-btn">确定</a>
      </div>
      <ul>
        <li>
          <div class="ate-stu">
            <div></div>
          </div>
          <div class="ate-data clearfix">
            <h3><%= studio["day_students"] %></h3>
            <h4>今日新增学员(人)</h4>
          </div>
        </li>
        <li class="mid">
          <div class="ate-stu">
            <div></div>
          </div>
          <div class="ate-data clearfix">
            <h3><%=  studio["total_price"] %></h3>
            <h4>今日营业金额(元)</h4>
          </div>
        </li>
        <li>
          <div class="ate-stu">
            <div></div>
          </div>
          <div class="ate-data clearfix">
            <h3><%= studio["total_price_lesson"] %></h3>
            <h4>今日课程消费(元)</h4>
          </div>
        </li>
      </ul>
      <div class="install">
        <a href="<%= admin_branchs_path(studio_id: studio["id"])%>">
        <div class="set-stdio">
          进入分店
        </div>
        </a>
      </div>
    </div>
  <% end %>
</div>

<div class="controls">
  <%= link_to '充值缴费', recharge_admin_companies_path, class: "pay" %>
  <%= link_to '添加分店', new_admin_studio_path, class: "add-studio" %>
</div>


<script type="text/javascript" src="/assets/js/res.js"></script>
<script type="text/javascript" src="/assets/js/common-list.js"></script>

<script type="text/javascript">
  $(function(){
    var leader = $(".ate-tip-name h2").text();
    $(".ate-tip-name .clearfix span").click(function(){  
      console.log("====");
      
      var that = $(this);
      $(this).parent().parent().css("display","none");
      $(this).parent().parent().parent().find(".ate-tip-input").css("display","block");

      $(".ate-btn").click(function(e){  
        console.log("====");
        var shopName = $(this).siblings(".ate-changing").val();
        var studioId = $(this).parent().attr("data_id");
        console.log("shopName",shopName,"id",studioId);
        $.ajax({
          type:'get', url:"/admin/studios/update_studio_name?shopName=" + shopName + "&studioId=" + studioId,
          success: function(data) {
            console.log(data);
            if(data.flag ==1){
              console.log(data.msg);
              location.reload(true);
            }else{
              console.log(data.msg);
            }
            
            // $(that).parent().parent().css("display","block");
            // $(that).parent().parent().parent().find(".ate-tip-input").css("display","none");
            // location.href = 
          }
        });
      });  
    }); 
  })
</script>
